import 'package:get/get.dart';
import 'package:series_play/bean/user_info_result_data.dart';
import 'package:series_play/comm/base/user_manager.dart';
import 'package:series_play/comm/event/event_data.dart';

/// 应用级控制器
///
/// 存放全局状态
class AppController extends GetxController {
  /// 是否登录
  ///
  /// 这里只能代表token 不为空
  // var isLogin = false.obs;

  /// 这里如果身份非游客时意味着已经正式用户登录
  var loginIdentity = LoginIdentity.guest.obs;

  bool get isLogin => loginIdentity.value == LoginIdentity.formalUser;

  Rxn<UserInfoData> userInfo = Rxn();

  /// 作为全局事件管理
  var eventBus = EventData().obs;

  @override
  void onReady() {
    super.onReady();
    UserManager.checkLogin();
  }

  void emitEvent(Object e) {
    eventBus.value = EventData(event: e);
  }
}
